package handle

import (
	"cow_golang/shared_mod/tcplib"
	"cow_golang/shared_mod/tcplib/iface"
	"fmt"
)

type HelloHandle struct {
	tcplib.BaseHandle
}

func (r *HelloHandle) PreHandle(request iface.IRequest) {
	fmt.Println("HelloRouter PreHandler")
}

func (r *HelloHandle) Handle(request iface.IRequest) {
	fmt.Println("HelloRouter Handler")
	// 读取请求
	fmt.Println("recv msg id:", request.GetID(),
		" data:", string(request.GetData()))
	// 回应请求
	err := request.GetSession().SendMsg(0, []byte("s hello world..."))
	if err != nil {
		fmt.Println("ping Handler error")
	}
}

func (r *HelloHandle) PostHandle(request iface.IRequest) {
	fmt.Println("HelloRouter PostHandle")
}
